package com.swssm.waveloop;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.util.Log;
import android.view.View;

public class WaveformSubtitleView extends View {
	
	private float scaleX = 1f; 
//	private float mNumSubtitleTime;
	private String mStrSubtitleText;
	private float mWidth;
	
	private static Path path;
	private static Paint mPaint;
	
	public WaveformSubtitleView(Context context,String strSubtitleText, long width) {
		super(context);
		
		mPaint = new Paint();
		mPaint.setColor(0xff7f7f00);
		mPaint.setStyle(Style.STROKE);

		//스페이스 처리
		if(strSubtitleText.contains("&nbsp;")){
			strSubtitleText = strSubtitleText.replaceAll("&nbsp;", "");
		}
		
		mStrSubtitleText = strSubtitleText;
		mWidth = width/10;
		
//		if( path == null )
//		{
//			path = new Path();
////			path.moveTo(0, 0);
////			path.lineTo(mWidth*2*scaleX, 0);
//			
//			//i 100개가 1초   입력받은 시간을 /100한 곳에 찍으면 된다
//			for(int i = 0; i < 10; ++i ){
//				
//				path.moveTo(input/100, 0);
//				
////				path.moveTo(10*i*scaleX, 0);
////				path.lineTo(10*i*scaleX, (i%10==0)?10:7);
//			}
//		}
		
		
	}

	protected void onDraw(Canvas canvas) {
		super.onDraw(canvas);
	
		//canvas.drawLine(0, 0, mWidth*2, 0, mPaint);
		//canvas.drawLine(0, 0, 0, 15, mPaint);
		/*
		for(int i = 0; i < 20; ++i ){
			canvas.drawLine(5*i, 0, 5*i, (i%10==0)?15:10, mPaint);
		}
		*/
		
		//확대를 위한 스케일링
//		Matrix matrix = canvas.getMatrix();
//		matrix.postScale(1f, 1f);
//		canvas.setMatrix(matrix);
		
//		canvas.drawPath(path, mPaint);
		canvas.drawLine(0, 0, 0, 15, mPaint);
		
		mPaint.setTextSize(10);
//		canvas.rotate(15f);
		canvas.drawText(mStrSubtitleText, 5, 10, mPaint);
//		canvas.draw
		
	}
	
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
	{
		setMeasuredDimension((int)(mWidth*scaleX), 15);
	}


	
	
}
